<!DOCTYPE html>
<html>
  <head>
    <title>Taylor Insurance - Dashboard</title>

      <link href="assets/css/700.css" rel="stylesheet">
      <link rel="stylesheet" href="assets/css/fontawesome-all.min.css">
      <script src="js/jQuery.min.js"></script>
      <script src="js/jquery.validate.min.js"></script>

      <script src="js/jquery.steps.js"></script>

      <style>
      html, body {
      min-height: 100%;
      }
      body, div, form, input, select, textarea, label, p { 
      padding: 0;
      margin: 0;
      outline: none;
      font-family: Roboto, Arial, sans-serif;
      font-size: 14px;
      color: #666;
      line-height: 22px;
      }
      h1 {
      position: absolute;
      margin: 0;
      font-size: 40px;
      color: #fff;
      z-index: 2;
 line-height: 83px;
      }
	  
	  
	  .buttons{
	  border:1px solid #fff;
	  padding: 10px 30px;
	  color: #fff;
	  text-decoration: none;
	  transition: 0.6s ease;
	  }
	  
	  .buttons:hover{
	  background-color: #fff;
	  color: #000;
	  }
	  
	  
      textarea {
      width: calc(100% - 12px);
      padding: 5px;
      }
      .testbox {
      display: flex;
      justify-content: center;
      align-items: center;
      height: inherit;
      padding: 20px;
      }
      form {
      width: 100%;
      padding: 20px;
      border-radius: 6px;
      background: #fff;
      box-shadow: 0 0 8px #006622; 
      }
      .banner {
      position: relative;
      height: 300px;
      background-image: url("/uploads/media/default/0001/02/e2502bb5e1dab7d5cc9b011c745033821aad632c.jpeg");  
      background-size: cover;
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
      }
      .banner::after {
      content: "";
      background-color: rgba(0, 0, 0, 0.2); 
      position: absolute;
      width: 100%;
      height: 100%;
      }
      input, select, textarea {
      margin-bottom: 10px;
      border: 1px solid #ccc;
      border-radius: 3px;
      }
      input {
      width: calc(100% - 10px);
      padding: 5px;
      }
      input[type="date"] {
      padding: 4px 5px;
      }
      textarea {
      width: calc(100% - 12px);
      padding: 5px;
    }
      .item:hover p, .item:hover i, .question:hover p, .question label:hover, input:hover::placeholder {
      color:  #006622;
      }
      .item input:hover, .item select:hover, .item textarea:hover {
      border: 1px solid transparent;
      box-shadow: 0 0 3px 0  #006622;
      color: #006622;
      }
      .item {
      position: relative;
      margin: 10px 0;
      }
      .item span {
      color: red;
      }
      input[type="date"]::-webkit-inner-spin-button {
      display: none;
      }
      .item i, input[type="date"]::-webkit-calendar-picker-indicator {
      position: absolute;
      font-size: 20px;
      color: #00b33c;
      }
      .item i {
      right: 1%;
      top: 30px;
      z-index: 1;
      }
 .week {
      display:flex;
      justfiy-content:space-between;
      }
      .colums {
      display:flex;
      justify-content:space-between;
      flex-direction:row;
      flex-wrap:wrap;
      }
      .colums div {
      width:48%;
      }
      [type="date"]::-webkit-calendar-picker-indicator {
      right: 1%;
      z-index: 2;
      opacity: 0;
      cursor: pointer;
      }
      input[type=radio], input[type=checkbox]  {
      display: none;
      }
      label.radio {
      position: relative;
  display: inline-block;
      margin: 5px 20px 15px 0;
      cursor: pointer;
      }
      .question span {
      margin-left: 30px;
      }
      .question-answer label {
      display: block;
      }
      label.radio:before {
      content: "";
      position: absolute;
      left: 0;
      width: 17px;
      height: 17px;
      border-radius: 50%;
      border: 2px solid #ccc;
      }
      input[type=radio]:checked + label:before, label.radio:hover:before {
      border: 2px solid  #006622;
      }
      label.radio:after {
      content: "";
      position: absolute;
      top: 6px;
      left: 5px;
      width: 8px;
      height: 4px;
      border: 3px solid  #006622;
      border-top: none;
      border-right: none;
      transform: rotate(-45deg);
      opacity: 0;
      }
      input[type=radio]:checked + label:after {
      opacity: 1;
      }
      .flax {
      display:flex;
      justify-content:space-around;
      }
      .btn-block {
      margin-top: 10px;
      text-align: center;
      }
	  
      button {
      width: 150px;
      padding: 10px;
      border: none;
      border-radius: 5px; 
      background:  #006622;
      font-size: 60px;
      color: #fff;
	  cursor: pointer;
      }
      button:hover {
      background:  #00b33c;
      }
	  
      @media (min-width: 568px) {
      .name-item, .city-item {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      }
      .name-item input, .name-item div {
      width: calc(50% - 20px);
      }
      .name-item div input {
      width:97%;}
      .name-item div label {
      display:block;
      padding-bottom:5px;
      }
      }
         
 .topnav {
  background-color: #333;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Change the color of links on hover */
.topnav a:hover {
  background-color: #ddd;
  color: black;
}

/* Add a color to the active/current link */
.topnav a.active {
  background-color: #4CAF50;
  color: white;
}

      table.blueTable {
          background-color: #EEEEEE;
          width: 100%;
          text-align: left;
          border-collapse: collapse;
      }
      table.blueTable td, table.blueTable th {
          border: 1px solid #AAAAAA;
          padding: 3px 2px;
      }
      table.blueTable tbody td {
          font-size: 13px;
      }
      table.blueTable tr:nth-child(even) {
          background: #D0E4F5;
      }
      table.blueTable thead {
          background: #DDDDDD;
          background: -moz-linear-gradient(top, #e5e5e5 0%, #e0e0e0 66%, #DDDDDD 100%);
          background: -webkit-linear-gradient(top, #e5e5e5 0%, #e0e0e0 66%, #DDDDDD 100%);
          background: linear-gradient(to bottom, #e5e5e5 0%, #e0e0e0 66%, #DDDDDD 100%);
          border-bottom: 2px solid #444444;
      }
      table.blueTable thead th {
          font-size: 15px;
          font-weight: bold;
          color: #121212;
          border-left: 2px solid #FFFFFF;
      }
      table.blueTable thead th:first-child {
          border-left: none;
      }

      table.blueTable tfoot {
          font-size: 14px;
          font-weight: bold;
          color: #FFFFFF;
          background: #D0E4F5;
          background: -moz-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
          background: -webkit-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
          background: linear-gradient(to bottom, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
          border-top: 2px solid #444444;
      }
      table.blueTable tfoot td {
          font-size: 14px;
      }
      table.blueTable tfoot .links {
          text-align: right;
      }
      table.blueTable tfoot .links a{
          display: inline-block;
          background: #1C6EA4;
          color: #FFFFFF;
          padding: 2px 8px;
          border-radius: 5px;
      }
    </style>
  </head>
  <body>
    <div class="testbox">
      <form>
        <div class="banner">
          <h1>Dashboard Homepage</h1>
        </div>
        <br/>    
              <div class="topnav">
  <a  href="index.html">Home</a>
  <a class="active" href="/dashboard.html">Dashboard</a>
  <a href="newpolicy.html">Contact</a>
  <a href="/login">Login</a>
 <a href="/logout">Logout</a>

              </div>
          <br>
		  <div class="buttons">
          <input id="inp3" type="button" value="ClientInformation" onclick="location.href='newpolicy.html';" />
          <input id="inp" type="button" value="New Home Policy" onclick="location.href='newhomepolicy.html';" />
          <input id="inp2" type="button" value="New Auto Policy" onclick="location.href='newautopolicy.html';" />
			</div>
          <fieldset>
          <legend>Dashboard</legend>

            <hr>
<p id = "client_name"><b>Welcome, CLIENTNAMEHERE</b></p>
            <p> Here are the policies that you currently have with us:</p>
            <br>

            <p><b>Home</b></p>

            <p id = "HomePolicyList"></p>

            <table class="blueTable">
                <thead>
                <tr>
                    <th>Policy Number</th>
                    <th>Coverage Type</th>
                    <th>Effective Date</th>
                    <th>Expiry Date</th>
                    <th>Estimated Premium</th>

                </tr>
                </thead>
                <tfoot>
                <tr>
                    <td colspan="4">
                    </td>
                </tr>
                </tfoot>
                <tbody>
                <tr>
                    <td id ="homePolicyNumber">*</td>
                    <td id ="homeCoverageType">*</td>
                    <td id ="homeEffectiveDate">*</td>
                    <td id ="homeExpiryDate">*</td>
                    <td id ="calculatedPremiumHome">*</td>

                </tr>
                </tbody>
            </table>
            <br>
            <p><b>Auto</b></p>

            <table class="blueTable">
                <thead>
                <tr>
                    <th>Policy Number</th>
                    <th>Coverage Type</th>
                    <th>Effective Date</th>
                    <th>Expiry Date</th>
                    <th>Estimated Premium</th>

                </tr>
                </thead>
                <tfoot>
                <tr>
                    <td colspan="4">
                    </td>
                </tr>
                </tfoot>
                <tbody>
                <tr>
                    <td id="autoPolicyNumber">*</td>
                    <td id="autoPolicyType">*</td>
                    <td id ="autoEffectiveDate">*</td>
                    <td id ="autoExpiryDate">*</td>
                    <td id ="calculatedPremium">*</td>

                </tr>
                </tbody>
            </table>


            <div>
<span id="result"></span>
        </div>
               </fieldset>


        <br/>
     
      </form>
    </div>
        
      <script>
          
          
           $("#calc1").click(function(event){

        //stop submit the form, we will get it manually.
        event.preventDefault();
      //  fire_ajax_submit();
    });
          
          
          $(document).ready(function() {
              
           $.getJSON("http://localhost:8080/api/client/1", function(data){
               $("#client_name").text("Welcome, " + data.main_insured_first_name + " " + data.main_insured_last_name );
            //   alert(data);
           })

              $.getJSON("http://localhost:8080/api/policy/home", function(data){
                  $("#homePolicyNumber").text(data.policy_number);
                  $("#homeCoverageType").text(data.policy_type);
                  $("#homeEffectiveDate").text(data.start_date);
                  var date = new Date(data.start_date);
                  date.setFullYear(date.getFullYear() + 1);
                  var month = date.getUTCMonth() + 1; //months from 1-12
                  var day = date.getUTCDate();
                  var year = date.getUTCFullYear();

                  newdate = year + "-" + month + "-" + day;
                  $("#homeExpiryDate").text(newdate);
                  $("#calculatedPremiumHome").text(data.term_price);
                  //   alert(data);
              })

              $.getJSON("http://localhost:8080/api/policy/auto", function(data){
                  $("#autoPolicyNumber").text(data.policy_number);
                  $("#autoPolicyType").text(data.policy_type);
                  $("#autoEffectiveDate").text(data.start_date);
                  $("#calculatedPremium").text(data.term_price);

                  var date = new Date(data.start_date);
                  date.setFullYear(date.getFullYear() + 1);
                  var month = date.getUTCMonth() + 1; //months from 1-12
                  var day = date.getUTCDate();
                  var year = date.getUTCFullYear();

                  newdate = year + "-" + month + "-" + day;
                  $("#autoExpiryDate").text(newdate);
                  //   alert(data);
              })






          });
          
          
function fire_ajax_submit_car() {

    var driverAge = $("#driverAge").val();
    var vehicleAge = $("#vehicleAge").val();
    var accidents_last_5_years = $("#accidentCount").val();
    var insuredCarWorth = $("#vehicleWorth").val();
    var carGaragedArea = $("#carGaragedArea").val();
       
    var carData = {
            driver_age: driverAge,
            vehicleAge: vehicleAge,
            accidentCount:accidents_last_5_years,
            vehicleWorth:insuredCarWorth,
            locationType:carGaragedArea
        }
    
    var jsonCarData = JSON.stringify(carData);
     
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "http://localhost:8080/api/auto_premium_rating",
        dataType: 'json',
        contentType: 'application/json',
        data: jsonCarData,   
        cache: false,
        timeout: 600000,
        success: function (data) { 
            console.log(data);          
            $("#result1").text(data.calculatedPremium);
        },
        error: function (e) {
            
            //  console.log( e );


          //  var json = "<h4>Ajax Response</h4>&lt;pre&gt;"
         //       + e.responseText + "&lt;/pre&gt;";
          //  $('#feedback').html(json);

          //  console.log("ERROR : ", e);
          //  $("#btn-search").prop("disabled", false);

        }
    });
}    
    function fire_ajax_submit_home() {
    var ageOfHome = $("#homeAge").val();
    var typeOfHouse = $("#typeOfHouse").val();
    var heatingType = $("#heatingType").val();
  
    var houseData = {
        homeAge: ageOfHome,
        heatingType: heatingType,
        dwellingType: typeOfHouse     
    }
    var jsonHouseData = JSON.stringify(houseData);
    console.log(jsonHouseData);  

    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "http://localhost:8080/api/home_premium_rating",
        dataType: 'json',
        contentType: 'application/json',
        data: jsonHouseData,   
        cache: false,
        timeout: 600000,
        success: function (data) {  
            console.log(data);              
            $("#result").text(data.calculatedPremium);
        },
        error: function (e) {
            
            //  console.log( e );


          //  var json = "<h4>Ajax Response</h4>&lt;pre&gt;"
         //       + e.responseText + "&lt;/pre&gt;";
          //  $('#feedback').html(json);

          //  console.log("ERROR : ", e);
          //  $("#btn-search").prop("disabled", false);

        }
    });
}          
      </script>
  </body>
       
</html>